package com.example.myapplication.apter;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.Outpatientappointment.AdministrativeofficeActivity;
import com.example.myapplication.Outpatientappointment.ModifyclientActivity;
import com.example.myapplication.R;
import com.example.myapplication.ShuJu.ClicktdepartmentBean;
import com.example.myapplication.ShuJu.ClientBean;
import com.google.gson.Gson;

import java.util.List;

public class ClicktdepartmentApter extends RecyclerView.Adapter<ClicktdepartmentApter.MyHolder>{
    private Context context;
    private List<ClicktdepartmentBean.RowsBean> list;

    public ClicktdepartmentApter(Context context, List<ClicktdepartmentBean.RowsBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public ClicktdepartmentApter.MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_clicktdepartment,null);
        return new ClicktdepartmentApter.MyHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ClicktdepartmentApter.MyHolder holder, int position) {
        holder.text_clicktdepartmentName.setText("门诊 :"+list.get(position).getCategoryName());
        holder.text_clicktdepartmentmoney.setText("收费 :"+list.get(position).getMoney()+"元");
        holder.Reentry_clicktdepartment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("ClicktdepartmentApter","======================");
                Intent intent = new Intent(context, AdministrativeofficeActivity.class);
                intent.putExtra("AdministrativeofficeActivityID",String.valueOf(list.get(position).getId()));
                intent.putExtra("AdministrativeofficeActivityName",String.valueOf(list.get(position).getCategoryName()));
                intent.putExtra("AdministrativeofficeActivityMoney",String.valueOf(list.get(position).getMoney()));
                context.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {

        TextView text_clicktdepartmentName;
        TextView text_clicktdepartmentmoney;
        RelativeLayout Reentry_clicktdepartment;


        public MyHolder(@NonNull View itemView) {
            super(itemView);

            text_clicktdepartmentName = itemView.findViewById(R.id.text_clicktdepartmentName);
            text_clicktdepartmentmoney = itemView.findViewById(R.id.text_clicktdepartmentmoney);
            Reentry_clicktdepartment = itemView.findViewById(R.id.Reentry_clicktdepartment);
        }
    }
}




